ScxV6Server.DeleteArea Method

Deletes an Area of Interest from the database.

Parameters

Remarks

You cannot delete the top level area of interest, where ID = 0. When the Force parameter is False, the DeleteArea method will fail if one or more database objects have references to the area of interest being deleted. When the Force parameter is True, any references to the deleted area of interest will be changed to the top level area of interest.

Example:

The following example written in VB.NET attempts to delete an Area of Interest.

Dim Svr As ScxV6DbClient.ScxV6Server

' Connect to the server

Svr = New ScxV6DbClient.ScxV6Server

Svr.Connect("MAIN", "", "")

' Find the area of interest called "Delete Me"

Dim Areas As ScxV6DbClient.ScxV6Areas

Areas = Svr.RootArea.List

Dim Area As ScxV6DbClient.ScxV6Area

For Each Area In Areas

If Area.Name = "Delete Me" Then

Try

Svr.DeleteArea(Area.ID, False)

Catch ex As System.Runtime.InteropServices.COMException

' Error returned, implying that the delete may have failed due to other objects referencing this area.

' Ask the user if they wish to attempt to delete anyway. Add the message returned with the exception, as

' it shows the reason the delete failed.

If (MsgBox(ex.Message + " Delete anyway?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok) Then

Svr.DeleteArea(Area.ID, True)

End If

End Try

End If

Next

' Disconnect

Svr.Disconnect()


Disclaimer

Geo SCADA Expert 2020